package top.bigdata.service;

import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import top.bigdata.mapper.ResultMapper;

@Service
@RequiredArgsConstructor
@Log4j2
/**
 * 定时任务
 */
public class ScheduledService {
    private final ResultMapper resultMapper;

    @Value("${app.cache-size}")
    private int limitNum;

    /**
     * 定时清理缓存
     */
    @Scheduled(initialDelay = 5000, fixedDelay = 120 * 1000)
    public void clearResult() {
        resultMapper.clearResult(limitNum);
    }

}